<template>
	<view class="my-attention">
		<view class="act-content">
			<view v-for="(item, index) in actList" :key="index" @click="itemClick(item)">
				<activityItem :actItem="item"></activityItem>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getAttentionActList,
		getACTList
	} from '@/config/api.js'

	import {
		mapState,
		mapGetters,
		mapActions
	} from 'vuex'

	import activityItem from '@/components/activityItem.vue'

	export default {
		components: {
			activityItem
		},
		data() {
			return {
				actList: [],
				actType: ''
			}
		},
		computed: {
			...mapGetters([
				'name',
				'account'
			])
		},
		methods: {
			async getAttentionActListFn() {
				const res = await getAttentionActList({
					params: {
						userAccount: this.account
					}
				})
				this.actList = res.data
			},
			itemClick(item) {
				uni.navigateTo({
					url: `/pages/activityDetail/activityDetail?actId=${item.actId}`
				});
			},

			async getACTListFn() {
				const res = await getACTList({
					params: {
						limit: 1000,
						offect: 1,
						organizerAccount: this.account
					}
				})
				console.log();
				this.actList = res.data.resList
			},

			onShow() {
				if (this.actType == '0') {
					this.getAttentionActListFn()
				} else if (this.actType == '1') {
					this.getACTListFn()
				}
			}
		},
		onLoad: function(option) {
			this.actType = option.actType
		}
	}
</script>

<style lang="scss" scoped>
	.act-content {
		padding: 10px 10px;
	}
</style>